package com.work.demo.file;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.util.HashMap;
import java.util.Map;

public class TestFilters {

	private static Map<String, String> sds(String responseStr) {
		Map<String, String> list = new HashMap<>(20);
		JSONObject jsonObject = JSONObject.parseObject(responseStr);
		String info = jsonObject.getString("info");
		JSONObject jsonObject1 = JSONObject.parseObject(info);
		JSONArray jsonArray = jsonObject1.getJSONObject("apply_data").getJSONArray("contents");
		for (int i = 0; i < jsonArray.size(); i++) {
			JSONObject jsonObject2 = jsonArray.getJSONObject(i);
			JSONArray title = jsonObject2.getJSONArray("title");
			if (title.toString().contains("体验环境节点信息")) {
				JSONObject value = jsonObject2.getJSONObject("value");
				JSONObject selector = value.getJSONObject("selector");
				JSONArray options = selector.getJSONArray("options");
				for (int j = 0; j < options.size(); j++) {
					JSONObject option = options.getJSONObject(j);
					JSONArray optionValue = option.getJSONArray("value");
					JSONObject valueObj = optionValue.getJSONObject(0);
					String nodeName = valueObj.getString("text");
//					List<SpNode> nodeList = spNodeService.getNodeList(nodeName);
//					list.put(nodeName, nodeList.get(0).getNodeDomain() + "," + nodeList.get(0).getAvatarAdr());
					list.put(nodeName, nodeName);
				}
			}


		}
		return list;
	}

	public static void main(String[] args) {
		Map<String, String> sds = sds("{\"errcode\":0,\"errmsg\":\"ok\",\"info\":{\"sp_no\":\"202108310001\",\"sp_name\":\"体验环境账号开通\",\"sp_status\":1,\"template_id\":\"BsAbK64JvDLHYv27DNDRVvWDTeUYhM1hwyj7cZ46y\",\"apply_time\":1630375326,\"applyer\":{\"userid\":\"YiQun\",\"partyid\":\"14\"},\"sp_record\":[{\"sp_status\":2,\"approverattr\":1,\"details\":[{\"approver\":{\"userid\":\"baoma\"},\"speech\":\"\",\"sp_status\":2,\"sptime\":1630375978,\"media_id\":[]}]},{\"sp_status\":2,\"approverattr\":1,\"details\":[{\"approver\":{\"userid\":\"QingShan\"},\"speech\":\"\",\"sp_status\":2,\"sptime\":1630376380,\"media_id\":[]}]},{\"sp_status\":1,\"approverattr\":1,\"details\":[{\"approver\":{\"userid\":\"LongDou\"},\"speech\":\"\",\"sp_status\":1,\"sptime\":0,\"media_id\":[]},{\"approver\":{\"userid\":\"MuYunBi\"},\"speech\":\"\",\"sp_status\":1,\"sptime\":0,\"media_id\":[]},{\"approver\":{\"userid\":\"gaozu\"},\"speech\":\"\",\"sp_status\":1,\"sptime\":0,\"media_id\":[]}]}],\"notifyer\":[],\"apply_data\":{\"contents\":[{\"control\":\"Tips\",\"id\":\"Tips-1629344238876\",\"title\":[{\"text\":\"说明\",\"lang\":\"zh_CN\"}],\"value\":{\"tips\":[],\"members\":[],\"departments\":[],\"files\":[],\"children\":[],\"stat_field\":[],\"sum_field\":[],\"related_approval\":[],\"students\":[],\"classes\":[]}},{\"control\":\"Selector\",\"id\":\"Selector-1628738457801\",\"title\":[{\"text\":\"体验环境节点信息\",\"lang\":\"zh_CN\"}],\"value\":{\"tips\":[],\"members\":[],\"departments\":[],\"files\":[],\"children\":[],\"stat_field\":[],\"selector\":{\"type\":\"multi\",\"options\":[{\"key\":\"option-1628738457801\",\"value\":[{\"text\":\"V2.0.4试用节点1\",\"lang\":\"zh_CN\"}]},{\"key\":\"option-1628738457802\",\"value\":[{\"text\":\"V2.0.4试用节点2\",\"lang\":\"zh_CN\"}]},{\"key\":\"option-1628738478711\",\"value\":[{\"text\":\"V2.0.4试用节点3\",\"lang\":\"zh_CN\"}]}]},\"sum_field\":[],\"related_approval\":[],\"students\":[],\"classes\":[]}},{\"control\":\"Text\",\"id\":\"Text-1629079851619\",\"title\":[{\"text\":\"客户名称\",\"lang\":\"zh_CN\"}],\"value\":{\"text\":\"重庆青竹\",\"tips\":[],\"members\":[],\"departments\":[],\"files\":[],\"children\":[],\"stat_field\":[],\"sum_field\":[],\"related_approval\":[],\"students\":[],\"classes\":[]}},{\"control\":\"Text\",\"id\":\"Text-1629079881983\",\"title\":[{\"text\":\"项目说明\",\"lang\":\"zh_CN\"}],\"value\":{\"text\":\"青竹为渠道代理商、目前需要节点供青竹使用对客户演示\",\"tips\":[],\"members\":[],\"departments\":[],\"files\":[],\"children\":[],\"stat_field\":[],\"sum_field\":[],\"related_approval\":[],\"students\":[],\"classes\":[]}},{\"control\":\"Text\",\"id\":\"Text-1629079900256\",\"title\":[{\"text\":\"功能模块\",\"lang\":\"zh_CN\"}],\"value\":{\"text\":\"联邦、mpc、匿踪\",\"tips\":[],\"members\":[],\"departments\":[],\"files\":[],\"children\":[],\"stat_field\":[],\"sum_field\":[],\"related_approval\":[],\"students\":[],\"classes\":[]}},{\"control\":\"Text\",\"id\":\"Text-1629079914847\",\"title\":[{\"text\":\"用户名\",\"lang\":\"zh_CN\"}],\"value\":{\"text\":\"qingzhu\",\"tips\":[],\"members\":[],\"departments\":[],\"files\":[],\"children\":[],\"stat_field\":[],\"sum_field\":[],\"related_approval\":[],\"students\":[],\"classes\":[]}},{\"control\":\"DateRange\",\"id\":\"DateRange-1618477910423\",\"title\":[{\"text\":\"使用天数\",\"lang\":\"zh_CN\"}],\"value\":{\"tips\":[],\"members\":[],\"departments\":[],\"files\":[],\"date_range\":{\"type\":\"halfday\",\"new_begin\":1630252800,\"new_end\":1630684800,\"new_duration\":475200,\"perday_duration\":86400},\"children\":[],\"stat_field\":[],\"sum_field\":[],\"related_approval\":[],\"students\":[],\"classes\":[]}}]},\"comments\":[]}}");
		System.out.println(sds.toString());
	}
}
